﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using mesoBoard.Data;
using mesoBoard.Data.Repositories;
using mesoBoard.Services;

namespace mesoBoard.Web.Models
{
    public class UserPermissions
    {
        public string UserName { get; private set; }
        public int Posting { get; private set; }
        public int Polling { get; private set; }
        public int Attachment { get; private set; }
        public bool Visible { get; private set; }

        public UserPermissions(User TheUser, Forum TheForum)
        {
            Forums forums = new Forums(new RepositoriesWrapper(new mbEntities()));

            this.Posting = forums.GetPermissionValue(TheForum.ForumID, TheUser.UserID, "Posting");
            this.Polling = forums.GetPermissionValue(TheForum.ForumID, TheUser.UserID, "Polling");
            this.Attachment = forums.GetPermissionValue(TheForum.ForumID, TheUser.UserID, "Attachment");
            this.Visible = forums.CanView(TheForum.ForumID, TheUser.UserID);
            this.UserName = TheUser.Username;
        }

    }
}
